package com.beiing.tianshuai.tianshuai.message.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CodeBean;
import com.beiing.tianshuai.tianshuai.entity.GroupDetailsBean;
import com.beiing.tianshuai.tianshuai.message.model.GroupDetailsModel;
import com.beiing.tianshuai.tianshuai.message.model.GroupDetailsModelImpl;
import com.beiing.tianshuai.tianshuai.message.view.GroupDetailsViewImpl;

import java.io.File;

/**
 * Created by Jinni on 2017/9/21 0021.
 */

public class GroupDetailsPresenter extends BasePresenter implements GroupDetailsPresenterImpl, GroupDetailsModel.OnRequestListener{

    private GroupDetailsViewImpl    mView;
    private GroupDetailsModelImpl   mModel;

    public GroupDetailsPresenter(GroupDetailsViewImpl view) {
        mView = view;
        mModel = new GroupDetailsModel(this);
    }

    @Override
    public void getGroupDetailsRequestResponse(String uid, String gid) {
        mView.showProgress();
        mModel.getGroupDetailsRequestResponse(uid, gid);
    }

    @Override
    public void getDismissGroupResult(String uid, String id, String groupId) {
        mView.showProgress();
        mModel.getDismissGroupResult(uid, id, groupId);
    }

    @Override
    public void getQuitGroupResult(String uid, String id, String groupId) {
        mView.showProgress();
        mModel.getQuitGroupResult(uid, id, groupId);
    }

    @Override
    public void getEditInvitedRootResult(String uid, String gid) {
        mModel.getEditInvitedRootResult(uid, gid);
    }

    @Override
    public void getUpdateAvatarResult(String uid, String id, File updateAvatar) {
        mModel.getUpdateAvatarResult(uid, id, updateAvatar);
    }

    @Override
    public void onSuccess(GroupDetailsBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onDismissSuccess(CodeBean bean) {
        mView.hideProgress();
        mView.onDismissGroupSuccess(bean);
    }

    @Override
    public void onQuitSuccess(CodeBean bean) {
        mView.hideProgress();
        mView.onQuitGroupSuccess(bean);
    }

    @Override
    public void updateAvatarSuccess(CodeBean bean) {
        mView.hideProgress();
        mView.onUpdateAvatarSuccess(bean);
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }
}
